package and.booze.now;

import android.app.ListActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListView;

public class Mainmenu extends ListActivity {

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		// requestWindowFeature(Window.FEATURE_NO_TITLE);
		// setContentView(R.layout.mainmenu);

		// lv1 = (ListView) findViewById(R.id.listview123);
		this.setListAdapter(new ArrayAdapter<String>(this,
				android.R.layout.simple_list_item_1, getResources()
						.getStringArray(R.array.games)));
	}

	@Override
	protected void onListItemClick(ListView l, View view, int position, long id) {
		super.onListItemClick(l, view, position, id);
		if (this.getListAdapter().getItem(position).toString()
				.equals(getResources().getStringArray(R.array.games)[0])) // booze
																			// computer
		{
			Intent intent = new Intent();
			intent.setClass(Mainmenu.this, BoozeComputer.class);
			startActivity(intent);
		} else if (this.getListAdapter().getItem(position).toString()
				.equals(getResources().getStringArray(R.array.games)[1])) // Meiern
		{
			Intent intent = new Intent();
			intent.setClass(Mainmenu.this, Meiern.class);
			startActivity(intent);
		} else if (this.getListAdapter().getItem(position).toString()
				.equals(getResources().getStringArray(R.array.games)[2])) // Test
		{
			Intent intent = new Intent();
			intent.setClass(Mainmenu.this, Test.class);
			startActivity(intent);
		}
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		MenuInflater inflater = getMenuInflater();
		inflater.inflate(R.menu.mainmenu, menu);
		return true;
	}

	@Override
	public boolean onOptionsItemSelected(MenuItem item) {
		switch (item.getItemId()) {
		case R.id.setting: {
			Intent intent = new Intent();
			intent.setClass(Mainmenu.this, Settings.class);
			startActivity(intent);
		}
			break;
		}
		return true;
	}
}
